#ifndef __I2C_H__
#define __I2C_H__

#include "cpu.h"
#include "includes.h"

typedef enum
{
    NACK = 0x00U,
    ACK = 0x01
} I2CAckStatus;

typedef enum
{
    WriteOK = 0x00U,
    WriteError = 0x01,
    ReadOK = 0x02U,
    ReadError = 0x03U
} I2CStatus;

#define I2C_WRITE   0xC0
#define I2C_READ    0xC1   

#define SDA_OUT()       GPIOB->CRH &= 0xf0ffffff;GPIOB->CRH |= 0x01000000;//0101
#define SDA_IN()        GPIOB->CRH &= 0xf0ffffff;GPIOB->CRH |= 0x08000000;GPIOB->ODR |= 1<<14;//0100

#define SDA_HIGH()      GPIOB->ODR |= (1<<14);
#define SDA_LOW()       GPIOB->ODR &= ~(1<<14);

#define SCK_LOW()       GPIOB->ODR &= ~(1<<13);
#define SCK_HIGH()      GPIOB->ODR |= (1<<13);

#define SDA_READ()      ((GPIOB->IDR)&(1<<14))

INT8U I2C_ReadReg(INT8U Reg);
I2CStatus I2C_WriteReg(INT8U Reg , INT8U Data);
I2CStatus I2C_WriteContinuity(INT8U Reg , INT8U *Data, INT8U Len);
extern void I2C_Test(void);

#endif



